package com.lp.batch.domain;

import java.util.ArrayList;
import java.util.List;

/**
 * A Node describes information encapsulated in a <node> element. A Node could
 * be a provice, city, country, or a continent.
 * 
 * @author Zainul Franciscus
 * 
 */
public class Node extends Element {

	/**
	 * an unique identifier for this node.
	 */
	private int atlasNodeId;

	/**
	 * stores the value of a ethyl_content_object_id
	 */
	private int ethylContentObjectId;
	/**
	 * Name of this node
	 */
	private String name;

	/**
	 * the parent node of this node.
	 */
	private Node parentNode;

	/**
	 * A description of this node
	 */
	private String description;
	
	
	
	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the parentNode
	 */
	public Node getParentNode() {
		return parentNode;
	}

	/**
	 * @return the name of the parent node
	 */
	public String getParentNodeName(){
		return parentNode.getName();
	}
	
	/**
	 * @return the id of the parent node
	 */
	public int getParentNodeId(){
		return parentNode.getAtlasNodeId();
	}
	/**
	 * @return true if this node has a parent node
	 */
	public boolean hasParentNode(){
		return (parentNode != null);
	}
	/**
	 * @param parentNode
	 *            the parentNode to set
	 */
	public void setParentNode(Node parentNode) {
		this.parentNode = parentNode;
	}

	/**
	 * @return the nodeId
	 */
	public int getAtlasNodeId() {
		return atlasNodeId;
	}

	/**
	 * @param nodeId
	 *            the nodeId to set
	 */
	public void setAtlasNodeId(int nodeId) {
		this.atlasNodeId = nodeId;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the ethylContentObjectId
	 */
	public int getEthylContentObjectId() {
		return ethylContentObjectId;
	}

	/**
	 * @param ethylContentObjectId
	 *            the ethylContentObjectId to set
	 */
	public void setEthylContentObjectId(int ethylContentObjectId) {
		this.ethylContentObjectId = ethylContentObjectId;
	}

	/**
	 * @return a parent node and all its descendants
	 */
	public List<Node> getAllNodes() {
		List<Node> nodes = new ArrayList<Node>();
		nodes.add(this);
		nodes.addAll(this.getDescendants());
		return nodes;
	}

}
